﻿using System;

//Gallio and MbUnit Framework
using MbUnit.Framework;

//MoQ Framework
using MockingBird.Simulator.Framework.Configuration;
using Moq;

namespace MockingBird.Simulator.FunctionalTests.CallChain
{
    using MockingBird.Common.Infrastructure.Logging;
    //Project references
    using MockingBird.Simulator.Framework;
    using MockingBird.Simulator.Framework.Handlers;
    using MockingBird.Simulator.Framework.Interfaces;


    [TestFixture]
    public class HandlerConstructionFixture
    {

        /// <summary>
        /// <summary>
        /// This test checks that the handler dispenser constructs the correct type of object
        /// and returns that instance (in a clean scenario)
        /// </summary>
        [Test]
        [Ignore]
        public void ExpectCorrectHandlerInstanceIsConstructedFromType()
        {
            var mockResolver = new Mock<IHandlerResolver>();
            var mockLogger = new Mock<ILogger>();
            var mockContext = new Mock<IExecutionContext>();
            var mockConfigProvider = new Mock<IConfigurationDataProvider>();
            var appConfig = new ApplicationConfiguration(mockConfigProvider.Object);
            var dispenser = new HandlerDispenser(mockResolver.Object, mockLogger.Object, appConfig);
            //setup - expectations
            //we dont really care what the context returns because in this case
            mockContext.Expect(x => x.EndpointFullName).Returns("customer.asmx");

            mockResolver.Expect(x => x.GetHandlerNameForEndpoint(It.IsAny<string>())).Returns("BasicSoapMessageHandler");

            Type handlerType = typeof(BasicSoapMessageHandler);
            mockResolver.Expect(x => x.GetHandlerType(It.IsAny<string>())).Returns(handlerType);
            //Now assert that the dispenser builds the right object
            Assert.IsInstanceOfType(typeof(BasicSoapMessageHandler), dispenser.GetHandler(mockContext.Object));


        }



    }
}
